<?php
include_once('general_include.php');

	$lesson_id=$_REQUEST['custom'];

	$Sql="SELECT lesson_status_id FROM ".TABLEPREFIX."_lesson_status WHERE lesson_status_title='Paid'";
	$Arr = $UserManagerObjAjax->GetRecords("Row",$Sql);
	
	$SqlLessonDetails="SELECT lesson_title,(SELECT name FROM ".TABLEPREFIX."_user WHERE user_id=".TABLEPREFIX."_lesson.student_id) AS name,(SELECT email FROM ".TABLEPREFIX."_user WHERE user_id=".TABLEPREFIX."_lesson.student_id) AS email FROM ".TABLEPREFIX."_lesson WHERE lesson_id=".$lesson_id;
	$LessonDetailsArr = $UserManagerObjAjax->GetRecords("Row",$SqlLessonDetails);
	
	$Sql_Up="UPDATE ".TABLEPREFIX."_lesson SET lesson_status_id=".$Arr['lesson_status_id'].",lesson_payment_transaction_no='".$_REQUEST['txn_id']."',lesson_payment_date='".date('Y-m-d')."' WHERE lesson_id=".$lesson_id;
	$Up=$UserManagerObjAjax->Execute($Sql_Up);
	
	$to  	  = $LessonDetailsArr['email'];
	$subject  = 'Payment Successful';
	$message  = '<h3>Dear '.$LessonDetailsArr['name'].',</h3>';
	$message .= 'Your payment for the lesson '.$LessonDetailsArr['lesson_title'].' is successful';
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: info@citytechsoftware.com' . "\r\n" .
				'Reply-To: sales@citytechsoftware.com' . "\r\n" .
				'X-Mailer: PHP/' . phpversion();
	
	mail($to, $subject, $message, $headers);
	
	exit;
	//header("location: payment_success.php");

?>